# 导入fastapi包
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
import uvicorn

app = FastAPI()
template = Jinja2Templates("pages")


@app.get("/")
def index(username, req: Request):
    # 把用户传递的username放入到魔板引擎中， 后端叫做username，前端叫做name
    return template.TemplateResponse("index.html", context={"request": req, "name": username})


if __name__ == '__main__':
    uvicorn.run(app)
